package pl.net.csrv.servlets;

import java.io.IOException;
import java.io.PrintWriter;

import javax.ejb.EJB;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import pl.net.csrv.dao.impl.UserDaoImpl;
import pl.net.csrv.ejb.impl.FBeanImpl;

/**
 * Servlet implementation class IntroduceServlet
 */
@WebServlet("/IntroduceServlet")
public class IntroduceServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
	@EJB
	FBeanImpl fBean;
	
	@EJB
	UserDaoImpl userDao;

    /**
     * Default constructor. 
     */
    public IntroduceServlet() {
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		PrintWriter out = response.getWriter();
		out.print("<HTML><HEAD></HEAD><BODY>");
		out.print("<H1>" + fBean.introduce() + "</H1>");
		out.print("<H2>" + userDao.findUserById(new Long(1)).getLogin() + "</H2>");
		out.print("</BODY></HTML>");
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
	}

}
